package jy.controller;

import jy.pageModel.Json;
import jy.pageModel.PFood;
import jy.pageModel.PUser;
import jy.service.FoodServiceI;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 食物控制器
 * 
 * @author JY
 * 
 */
@Controller
@RequestMapping("/food")
public class FoodController extends BaseController {
	@Autowired
	private FoodServiceI foodService;
	
	@ResponseBody
	@RequestMapping("/add")
	public Json add(PFood food) {
		Json j = new Json();
		try {
			foodService.add(food);
			j.setSuccess(true);
			j.setMsg("添加成功！");
		} catch (Exception e) {
			e.printStackTrace();
			j.setMsg("添加出现错误！");
		}
		return j;
	}
	
}
